package com.fy.fyspace.common.result;
import lombok.Data;
@Data
public class Result<T> {
    private static final Integer SUCCESS_CODE=200;
    private static final Integer ERROR_CODE=400;
    private static final String SUCCESS = "请求成功";
    private static final String ERROR = "请求失败";
    private Integer code;
    private String status;
    private String message;
    private T data;

    public Result(Integer code, String status, String message, T data) {
        this.code = code;
        this.status = status;
        this.message = message;
        this.data = data;
    }
    public static <T> Result<T> success() {
        return new Result<>(SUCCESS_CODE, SUCCESS, null, null);
    }
    public static <T> Result<T> success(T data) {
        return new Result<>(SUCCESS_CODE, SUCCESS, null, data);
    }
    private static <T> Result<T> error() {
        return new Result<>(ERROR_CODE, ERROR, null, null);
    }
    public static <T> Result<T> error(String message) {
        return new Result<>(ERROR_CODE, ERROR, message, null);
    }
}